package com.itfenghuang.day07_作业;

import com.itfenghuang.day01_作业.Student_7;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.Random;
import java.util.TreeSet;

public class A01_作业 {
    public static void main(String[] args) {
//        1.已知一个集合容器ArrayList中 存储了"aaa" "bbb" "ccc" "aaa" "aaa",要求删除所有的"aaa"
        ArrayList list = new ArrayList();
        list.add("aaa");
        list.add("bbb");
        list.add("ccc");
        list.add("aaa");
        list.add("aaa");
        Iterator y = list.iterator();
        while (y.hasNext()) {
            if (y.next().equals("aaa")) {
                y.remove();
                System.out.println(list);
            }
        }




//        2.定义String getStr(char[] chs)静态方法，方法内要求：获取长度为5的随机字符串，
//        字符串由随机的4个大写英文字母和1个0-9之间（包含0和9）的整数组成
//        定义main方法，方法内完成：
//	        （1）定义长度为26，元素值为26个大写英文字母的数组chs


//	        （2）传递数组chs调用getStr(char[] chs)方法，获取返回值,并在控制台打印返回值

//        3.请按以下要求编写代码：
//        1.定义Student类，包含以下属性：
//        学号、姓名、身高
//        2.定义MainApp类，包含main()方法；
//        3.在main()方法中，创建一个可以存储Student对象的集合对象；
//        4.创建以下几个Student对象：
//        学号		姓名		身高
//        a001		黄渤		1.72
//        a002		孙红雷		1.78
//        a003		章子怡		1.64
//        a004		杨颖		1.68
        ArrayList xx = new ArrayList();
        xx.add(new Student("a001", "黄渤", "1.72"));
        xx.add(new Student("a002", "孙红雷", "1.78"));
        xx.add(new Student("a003", "詹子怡", "1.64"));
        xx.add(new Student("a004", "杨颖", "1.68"));

        System.out.println(xx);
        System.out.println(xx.size());
        System.out.println(xx.get(2));
        System.out.println(xx.remove(3));
        System.out.println(xx.size());
        System.out.println(xx.set(0, new Student("s005","撒贝宁","67")));
        System.out.println(xx);
//  第二题
        Iterator aa = xx.iterator();
        while (aa.hasNext()){
            System.out.println(aa.next());
        }

        char[] chars = new char[26];
        for (int i = 65, j = 0; i < 91; i++, j++) {
            char A = (char) i;
            chars[j] = A;
        }
        System.out.println(chars);
        System.out.println(getString1(chars));

        //    第四题
        TreeSet<Employee> tt = new TreeSet<>();
        tt.add(new Employee("阿刁",19,5789));
        tt.add(new Employee("c阿狗",17,3500));
        tt.add(new Employee("阿猫",28,4680));
        tt.add(new Employee("d阿吉",17,3500));
        tt.add(new Employee("啊呸",18,3200));
        System.out.println(tt);
    }

    public static String getString1(char[] chs) {

        String aa = "[";
        for (int i = 0; i < 4; i++) {
            double v = Math.random() * 27;
            int xx = (int) v;
            aa += chs[xx];
        }
        int[] bb = new int[10];
        for (int i = 0; i < 10; i++) {
            bb[i] = i;
        }
        double v = Math.random() * 10;
        int xx = (int) v;
        String ss = aa += bb[xx] + "]";
        return ss;
    }



    }


//第三题
class Student{
    private String id;
    private String name;
    private String height;

    public Student() {
    }

    public Student(String id, String name, String height) {
        this.id = id;
        this.name = name;
        this.height = height;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getHeight() {
        return height;
    }

    public void setHeight(String height) {
        this.height = height;
    }

    @Override
    public String toString() {
        return "Student{" +
                "id='" + id + '\'' +
                ", name='" + name + '\'' +
                ", height='" + height + '\'' +
                '}';
    }


}
//第四题

class Employee implements Comparable<Employee>{
    private String name;
    private int age;
    private int salary;

    public Employee() {
    }

    public Employee(String name, int age, int salary) {
        this.name = name;
        this.age = age;
        this.salary = salary;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public int getSalary() {
        return salary;
    }

    public void setSalary(int salary) {
        this.salary = salary;
    }

    @Override
    public String toString() {
        return "Employee{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", salary=" + salary +
                '}';
    }

    @Override
    public int compareTo(Employee o) {
        int i=this.salary-o.salary>=0 ? o.salary-this.salary:1;
        int i1=i==0?this.age-o.age:i;
        int i2=i1==0?this.name.compareTo(o.name):i1;
        int i3=i2==0?this.name.compareTo(o.name):i2;
        return i3;
    }
}